#include<stdio.h>
#include<conio.h>
#include<string.h>

struct sinhvien
{      char ma[10];
       char ht[10];
       float diem1;
       float diem2;
       float diem3;
       float diem4;
       char hk[10];  
       };
void nhap(sinhvien a[],int &n)
{    printf(" nhap so sinh vien");
     scanf("%d",&n);
     for(int i=0;i<n;i++)
     {
             printf(" nhap thong tin sinh vien thu %d:",i+1);
             fflush(stdin);
             printf("\nnhap ma sv:");
             gets(a[i].ma);
             printf("\nnhap ho ten: ");
             gets(a[i].ht);
             printf("\nhap diem mon 1 2 3 4:");
             scanf("%f %f %f %f",&a[i].diem1,&a[i].diem2,&a[i].diem3,&a[i].diem4);
     		 fflush(stdin);
     		 printf("\n nhap hanh kiem sinh vien: ");
     		 gets(a[i].hk);
	 }
 }
 void in(sinhvien a[],int n)
 {
      printf("	\n danh sach sinh vien ");
      printf(" | ma sv | ho ten | diem mon 1-2-3-4   | hanh kiem | \n");
      for(int i=0; i<n; i++)
      printf(" |%s | %s |  %0.1f |  %0.1f |  %0.1f  |  %0.1f  |  %s  | \n ",a[i].ma,a[i].ht,a[i].diem1,a[i].diem2,a[i].diem3,a[i].diem4,a[i].hk);
  }
void them(sinhvien a[],int n,int vt)
{	int i;
	printf(" Them 1 sinh vien vao trong mang");
	for(i=n;i>vt;i--) 
	a[i]=a[i-1];
	printf(" nhap thong tin sinh vien moi");
            fflush(stdin);
             printf("\nnhap ma sv:");
             gets(a[vt].ma);
             printf("\nnhap ho ten: ");
             gets(a[vt].ht);
             printf("\nhap diem mon 1 2 3 4:");
             scanf("%f %f %f %f",&a[vt].diem1,&a[vt].diem2,&a[vt].diem3,&a[vt].diem4);
     		 fflush(stdin);
     		 printf("\n nhap hanh kiem sinh vien: ");
     		 gets(a[vt].hk);
	in(a,n+1);
}
int main()
{	sinhvien a[10];
	int n,x;
	nhap(a,n);
	in(a,n);
	printf("nhap vi tri them sinh vien");
	scanf("%d",&x);
	them(a,n,x);
	getch();
}
